<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

  <script>
    function getSum(start, end) {
      let sum = 0;
      for (let i = start; i <= end; i++) {
        sum += i;
      }
      console.log(sum);
    }

    let start = +prompt('请输入起始数字')
    let end = +prompt('请输入结束数字')
    getSum(start, end)
  </script>
</body>

</html>